﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace APP.HELPER.Utils.CustomizeToolbox
{
    public class DataGridViewCalendarCell : DataGridViewTextBoxCell
    {
        public override Type EditType
        {
            get
            {
                return typeof(CalendarEditingControl);
            }
        }
        public override Type ValueType
        {
            get
            {
                return typeof(DateTime);
            }
        }
        public override object DefaultNewRowValue
        {
            get
            {
                return DateTime.Now;
            }
        }
        public DataGridViewCalendarCell()
        {
            base.Style.Format = "dd/MM/yyyy";
        }
        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            CalendarEditingControl calendarEditingControl = base.DataGridView.EditingControl as CalendarEditingControl;
            calendarEditingControl.Value = GridCalendarControlLib.ToDate(base.Value);
        }
    }
}
